#{extends 'CRUD/layout.html' /}

<div id="crudShow" class="${type.name}">
	
	<h2 id="crudShowTitle">&{'crud.show.title', type.modelName}</h2>
	
	<div class="objectForm">
	#{form action:@save(object.id), enctype:'multipart/form-data'}
		#{crud.form}
			#{crud.custom 'assignments'}#{/crud.custom}
		#{/crud.form}
		<p class="crudButtons">
			<input type="submit" name="_save" value="&{'crud.save', type.modelName}" />
			<input type="submit" name="_saveAndContinue" value="&{'crud.saveAndContinue', type.modelName}" />
		</p>
	#{/form}
	</div>
	
	#{form @delete(object.id)}
		<p class="crudDelete">
			<input type="submit" value="&{'crud.delete', type.modelName}" />
		</p>
	#{/form}
</div>
<ul><li><a href="/admin/assignments/new?object.course@id=${object.id}">Add Assignment</a></li>
<li><a href="javascript:;" onclick="$('#tutorial_form').toggle();">Add Tutorials</a>
<div id="tutorial_form" style="#{ifnot flash.success}display:none;#{/ifnot}">
	<form onsubmit="return add_tutorials();">
		<input type="text" id="tutorials" /> <input type="submit" value="Add tutorials"/><br />
		<div class="tiny_info _bbb">Comma separated</div>
	</form>
</div>
</li></ul>


<script type="text/javascript">
	function add_tutorials()
	{
		$.post('/ajax/addTutorials', 
				{courseId: ${object.id},
				tutorials: $('#tutorials').val()}, function(data){
					location.reload();
				});
		return false;
	}

</script>